package com.yn.service.zy.model.dto;

import com.yn.common.model.zy.TDeviceInfoDO;
import com.yn.common.utils.BeanUtils;
import com.yn.common.utils.MoneyUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.ObjectUtils;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;

/**
 * @ClassName: TDeviceInfoDTO
 * @Description:
 * @Author: lxp
 * @Date: 2025/5/7 11:24
 **/
@Data
@ApiModel("设备出参")
public class TDeviceInfoDTO {
    @ApiModelProperty("主键id")
    private Integer id;

    @ApiModelProperty("设备名称")
    private String deviceName;

    @ApiModelProperty("设备图片")
    private String deviceImageUrl;

    @ApiModelProperty("设备介绍")
    private String deviceIntro;

    @ApiModelProperty("设备租金")
    private BigDecimal deviceRent;

    @ApiModelProperty("单位(次/天)字典")
    private String rentalUnit;

    @ApiModelProperty("设备押金")
    private BigDecimal equipmentDeposit;

    public static TDeviceInfoDTO transform(TDeviceInfoDO tDeviceInfoDO){
        if (ObjectUtils.isEmpty(tDeviceInfoDO)) {
            return null;
        }

        TDeviceInfoDTO tDeviceInfoDTO = BeanUtils.copyProperties(tDeviceInfoDO, TDeviceInfoDTO.class);
        if (Objects.nonNull(tDeviceInfoDO.getDeviceRent())){
            tDeviceInfoDTO.setDeviceRent(MoneyUtils.fen2yuan(tDeviceInfoDO.getDeviceRent()));
        }
        if (Objects.nonNull(tDeviceInfoDO.getEquipmentDeposit())){
            tDeviceInfoDTO.setEquipmentDeposit(MoneyUtils.fen2yuan(tDeviceInfoDO.getEquipmentDeposit()));
        }

        return tDeviceInfoDTO;
    }
}
